﻿using SuddenDeath.Domain.Services.FileManager.elFinder.Utils;

namespace SuddenDeath.Domain.Services.FileManager.elFinder
{
    public class Cdc
    {
        public string name { get; set; }

        public string hash { get; set; }

        public string url { get; set; }

        public string date { get; set; }

        public string mime { get; set; }

        public long size { get; set; }

        public bool read { get; set; }

        public bool write { get; set; }

        public bool rm { get; set; }

        public Cdc(System.IO.DirectoryInfo dir)
        {
            date = dir.LastWriteTime.ToShortDateString();
            name = dir.Name;
            read = write = rm = true;
            mime = "directory";
            size = dir.Size();
            hash = dir.FullName.Hash();
            url = "/" + dir.PathFromRoot().Replace(@"\", "/");
        }

        public Cdc(System.IO.FileInfo file)
        {
            date = file.LastWriteTime.ToShortDateString();
            name = file.Name;
            mime = file.GetMimeType();
            size = file.Length;
            read = write = rm = true;
            hash = file.FullName.Hash();
            url = "/" + file.Directory.PathFromRoot().Replace(@"\", "/") + "/" + file.Name;
        }
    }
}
